import Vue from "vue";
import VueRouter from "vue-router";
import HomeView from "../views/HomeView.vue";
import store from "@/store/index";
Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/home/index",
  },
  {
    path: "/home",
    name: "home",
    component: HomeView,
    children: [
      // 首页
      {
        path: "index",
        name: "index",
        component: () => import('../views/home/Index.vue')
      },
      // 演唱会
      {
        path: "vocal",
        name: "vocal",
        component: () => import('../views/home/Vocal.vue')
      },

      // 帮助中心
      {
        path: "help",
        name: "help",
        component: () => import('../views/home/Help.vue'),
        children: [
          {
            path: 'helpmenu1',
            component: () => import('../views/home/helpmenu1.vue')
          },
          {
            path: 'helpmenu2',
            component: () => import('../views/home/helpmenu2.vue')
          },
          {
            path: 'helpmenu3',
            component: () => import('../views/home/helpmenu3.vue')
          },
          {
            path: 'helpmenu4',
            component: () => import('../views/home/helpmenu4.vue')
          },
          {
            path: 'helpmenu5',
            component: () => import('../views/home/helpmenu5.vue')
          },
          {
            path: 'helpmenu6',
            component: () => import('../views/home/helpmenu6.vue')
          },
          {
            path: 'helpmenu7',
            component: () => import('../views/home/helpmenu7.vue')
          },
          {
            path: 'helpmenu8',
            component: () => import('../views/home/helpmenu8.vue')
          },
          {
            path: 'helpmenu9',
            component: () => import('../views/home/helpmenu9.vue')
          },
          {
            path: 'helpmenu10',
            component: () => import('../views/home/helpmenu10.vue')
          },
          {
            path: 'helpmenu11',
            component: () => import('../views/home/helpmenu11.vue')
          },
          {
            path: 'helpmenu12',
            component: () => import('../views/home/helpmenu12.vue')
          },
          {
            path: 'helpmenu13',
            component: () => import('../views/home/helpmenu13.vue')
          },
          {
            path: 'helpmenu14',
            component: () => import('../views/home/helpmenu14.vue')
          },
        ]
      },
      // 关于我们
      {
        path: "about",
        name: "about",
        component: () => import('../views/home/About.vue'),
        children: [
          {
            path: 'aboutmenu1',
            component: () => import('../views/home/aboutmenu1.vue')
          },
          {
            path: 'aboutmenu2',
            component: () => import('../views/home/aboutmenu2.vue')
          },
          {
            path: 'aboutmenu3',
            component: () => import('../views/home/aboutmenu3.vue')
          },
          {
            path: 'aboutmenu4',
            component: () => import('../views/home/aboutmenu4.vue')
          },
        ]
      },
    ],
  },
  // 详情页
  {
    path: "/content",
    name: "content",
    component: () => import('../views/ContentView.vue'),
    children: [
      {
        path: "address",
        name: "address",
        component: () => import('../views/content/AddressView.vue')
      },
      {
        path: "buy",
        name: "buy",
        component: () => import('../views/content/BuyView.vue')
      },
      {
        path: "pay",
        name: "pay",
        component: () => import('../views/content/PayView.vue')
      },
    ]
  },
  // 个人中心
  {
    path: "/user",
    name: "user",
    component: () => import('../views/user/User.vue'),
    children: [
      // 我的订单
      // 想看的演出
      {
        path: 'wddd1',
        component: () => import('../views/user/wddd1.vue'),
        children: [
          {
            path: 'dpdd',
            component: () => import('../views/user/dpdd.vue')
          },
          {
            path: 'lsdd',
            component: () => import('../views/user/lsdd.vue')
          },
        ]
      },
      {
        path: 'wddd2',
        component: () => import('../views/user/wddd2.vue')
      },
      {
        path: 'wddd3',
        component: () => import('../views/user/wddd3.vue'),
        children: [
          {
            path: 'myml',
            component: () => import('../views/user/myml.vue')
          },
          {
            path: 'mlmx',
            component: () => import('../views/user/mlmx.vue')
          },
        ]
      },
      {
        path: 'wddd4',
        component: () => import('../views/user/wddd4.vue')
      },
      {
        path: 'wddd5',
        component: () => import('../views/user/wddd5.vue')
      },
    ]
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

// 设置全局前置守卫,每当路由跳转时执行(在显示目前组件之前执行)
// 其中的to和from其实都是一个route对象
router.beforeEach((to, from, next) => {
  if (1 === 1) {
    next();
    return;
  }
  // if (to.path == "/user/login" || store.state.user) {
  //   next();
  // } else {
  //   router.push("/user/login");
  // }
});

export default router;
